package org.example.controller;

import org.example.entity.Product;
import org.example.param.ProductParam;
import org.example.service.ProductService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.Map;

@RestController
@RequestMapping("/product")
public class ProductController {
    @Resource
    ProductService productService;

    @PostMapping("/save")
    public Map<String, Object> save(Product product) {
        return productService.save(product);
    }
    @GetMapping("/page")
    public Map<String,Object> page(ProductParam param) {
        return productService.page(param);
    }
    @PostMapping("/disable")
    public Map<String, Object> disable(Product product) { return productService.disable(product);}
    @PostMapping("/batch-import")
        public Map<String, Object> batchImport(MultipartFile file) {
            return productService.importExcel(file);
        }
    }


